package com.itheima.demo01Lambda;

public class Demo02LambdaUse {

    public static void main(String[] args) {
        goSwimming(new Swimmable() {
            @Override
            public void swimming() {
                System.out.println("我是匿名内部类的游泳");
            }
        });
        goSwimming(
                () -> System.out.println("我是Lambda的游泳"));
        System.out.println("------------------");
        goSmoking(new Smokeable() {
            @Override
            public int smoking(String name) {
                System.out.println("匿名内部类抽了" + name + "的烟");
                return 5;
            }
        });

        goSmoking(name ->
                {
                    System.out.println("Lambda抽了" + name + "的烟");
                    return 6;
                }
        );


    }

    //练习有参数返回值的Lambda
    public static void goSmoking(Smokeable s) {
        int i = s.smoking("中华");
        System.out.println("返回值:" + i);
    }

    //练习无参数返回值的Lambda
    public static void goSwimming(Swimmable s) {
        s.swimming();
    }
}
